<template>
    <el-container class="container" :style="{ height:h + 'px' }">
      <el-header class="c-header" v-permission="['createImageClass,POST','uploadImage,POST']">
          <el-button type="primary" size="small" @click="handleOpenCreate" v-permission="['createImageClass,POST']">新增图片分类</el-button>
          <el-button type="warning" size="small" @click="handleOpenUpload" v-permission="['uploadImage,POST']">上传图片</el-button>
      </el-header>
      <el-container>
        <el-aside width="220px">
            <image-aside ref="imageAsideRef" @change="handleAsideChange"></image-aside>
        </el-aside>
        <el-main>
            <image-main ref="imageMainRef"></image-main>
        </el-main>
      </el-container>
    </el-container>
</template>
<script setup>
import { ref } from 'vue'
import ImageAside from '~/components/ImageAside.vue'
import ImageMain from '~/components/ImageMain.vue'

// 容器高度
const windowHeight = window.innerHeight || document.body.clientHeight
const h = ref(windowHeight - 64 - 44)

const imageMainRef = ref(null)
const imageAsideRef = ref(null)

// 新增图片分类
const handleOpenCreate = () => imageAsideRef.value.openCreate()
// 上传图片
const handleOpenUpload = () => {
    imageMainRef.value.openUpload()
}
 // 选中图库
const handleAsideChange = (image_class_id)=>{
    imageMainRef.value.loadData(image_class_id)
}
</script>
<style lang="scss" scoped>
@mixin center() {
    display: flex;
    align-items: center;
}
$background: #fff;
.container {
    border-radius: 4px;
    .c-header {
        background: $background !important;
        border-radius: 8px 8px 0 0;
        border-bottom: 1px solid #eee;
        height: 60px;
        @include center;
        padding: 0 20px;
    }
}
</style>